#
# Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
#
# GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
# Author: Shawn.Tan
# Date: 2025.10.28
#
# History: Initial Version 2025.10.28
#
#
from base.Sequence import Sequence
from gpgpu.EnvGPGPU import EnvGPGPU
from gpgpu.GenThreadGPGPU import GenThreadGPGPU


# ******************************************************************
#   Generate Floating point instructions
#
# ******************************************************************


class MainSequence(Sequence):
    def generate(self, **kargs):

        instrCount = 10  # How many instructions should be generated in the test case.

        # "ALL" indicates randomly select from the set of instructions in
        # the instructionSubset.
        # Or you can...
        # specify a single instruction type to be generated in the test case
        # Find the correct string specifying the instruction you want
        # in the <greencode checkout base dir>/GreenCode/gpgpu/arch_data/
        # gpgpu_instruction.xml file.

        instrType = "ALL"

        # if you specify instrType="ALL", instructions will be generated from
        # this set of instructions
        instructionSubset = {
            "FMUL.D##CALM": 20,
            "FMUL.S##CALM": 20,
            "FDIV.D##CALM": 20,
            "FDIV.S##CALM": 20,
            "FMADD.D##CALM": 20,
            "FMADD.S##CALM": 20,
            "FADD.D##CALM": 20,
            "FADD.S##CALM": 20,
        }

        # gen each instruction
        for i in range(instrCount):

            # if ctrl file instrType option=ALL, randomly pick each instruction
            if instrType == "ALL":

                # Pick a random instruction from the instructionSubset
                theInstruction = self.pickWeighted(instructionSubset)
                self.genInstruction(theInstruction)

            else:

                theInstruction = instrType
                self.genInstruction(theInstruction)


# Points to the MainSequence defined in this file
MainSequenceClass = MainSequence

# Using GenThreadGPGPU by default, can be overriden with extended classes
GenThreadClass = GenThreadGPGPU

# Using EnvGPGPU by default, can be overriden with extended classes
EnvClass = EnvGPGPU
